package xin.marcher.module.diplomacy.domain.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
 * 商品搜索请求结果
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PorductSearchDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 命中的商品id
     */
    List<String> skuIds;

    /**
     * 总记录数
     */
    private long totalCount;

    /**
     * 页码
     */
    private int pageNum;

    /**
     * 每页条数
     */
    private int pageSize;

    /**
     * 去重之后的品牌信息
     */
    Set<BrandInfo> brandInfos;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class BrandInfo implements Serializable {

        /**
         * 品牌id
         */
        private Long brandId;

        /**
         * 品牌名称
         */
        private String brandName;

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            BrandInfo brandInfo = (BrandInfo) o;
            return Objects.equals(brandId, brandInfo.brandId) && Objects.equals(brandName, brandInfo.brandName);
        }

        @Override
        public int hashCode() {
            return Objects.hash(brandId, brandName);
        }
    }
}
